package dgut.lgc;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

import java.util.Arrays;

@SpringBootApplication
@Slf4j
public class LgcApplication {

    public static void main(String[] args) {
        SpringApplication.run(LgcApplication.class, args);
    }

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext context) {
        return args -> {
            log.info("SpringBoot注册的所有bean如下：");
            final String[] beanDefinitionNames = context.getBeanDefinitionNames();
            Arrays.stream(beanDefinitionNames)
                    .sorted()
                    .forEach(System.out::println);
        };
    }

}
